package com.jwgf.smarowindingmachine_unity.ui;

import android.app.AlertDialog;
import android.app.Dialog;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;

import com.jwgf.qrcode.QRCodeUtil;

public class QRCodeDialog extends DialogFragment {
    public static final String CONTENT = "content";

    @NonNull
    @Override
    public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
        String content = getArguments().getString(CONTENT, "");
        Bitmap bitmap = QRCodeUtil.createQRCodeBitmap(content, 240, 240);
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        ImageView imageView = new ImageView(getActivity());
        imageView.setImageBitmap(bitmap);
        builder.setView(imageView);
        return builder.create();
    }
}
